public class CQueue {
    int[] head;
    int[] tail;
    int header;
    int tailer;

    public static void main(String[] args) {
        CQueue obj = new CQueue();
        obj.appendTail(2);
        System.out.println(obj.deleteHead());
        obj.appendTail(3);
        obj.appendTail(1);
        System.out.println(obj.deleteHead());
        System.out.println(obj.deleteHead());
        System.out.println(obj.deleteHead());
    }

    public CQueue() {
        this.head = new int[5000];
        this.tail = new int[5000];
        this.header = 0;
        this.tailer = 0;
    }
    
    public void appendTail(int value) {
        if(this.header == 5000){
            if(this.tailer == 5000){
            return ;
            }else{
                while((this.tailer < 5000)&&(this.header > 0))
                    this.tail[this.tailer++] = this.head[--this.header];
            }
        }
        this.head[this.header++] = value;
    }
    
    public int deleteHead() {
        if(this.tailer == 0){
            if(this.header == 0){
                return -1;
            }else{
                while((this.tailer < 5000)&&(this.header > 0))
                    this.tail[this.tailer++] = this.head[--this.header];
            }
        }
        return this.tail[--this.tailer];
    }
}

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue obj = new CQueue();
 * obj.appendTail(value);
 * int param_2 = obj.deleteHead();
 */